package com.cskaoyan.day03.generic5;


/**
 * @author stone
 * @date 2022/01/29 11:18
 */
public class GenericDemo5 {

    public static void main(String[] args) {
        int tag = 0;
        MysteryBox<?> mysteryBox;
        if (tag == 1) {
            mysteryBox = new MysteryBox<String>();
        }else {
            MysteryBox<Integer> mysteryBox1 = new MysteryBox<>();
            mysteryBox = mysteryBox1;
        }

        //并不是预期结果，因为我们想要向里面放的Integer
        //mysteryBox.setValue("红");

        //MysteryBox2.show(new MysteryBox2<Exception>());
        //MysteryBox2.show(new MysteryBox2<RuntimeException>());
        //MysteryBox2.show(new MysteryBox2<String>());

        MysteryBox<? extends Exception> mysteryBox1 = new MysteryBox<>();
        MysteryBox<? super Exception> mysteryBox2 = new MysteryBox<>();

        //Son extends Father
        //Father father = new Son();
        //Son son = new Father();
        //mysteryBox1.setValue(new Exception());
        mysteryBox2.setValue(new Exception());
        //mysteryBox1.setValue(new RuntimeException());
        mysteryBox2.setValue(new RuntimeException());

        MysteryBox<String> mysteryBox3 = new MysteryBox<>();
        /*if (mysteryBox3 instanceof MysteryBox<String>) {

        }*/

        MysteryBox mysteryBox4 = new MysteryBox();

        MysteryBox<Integer> mysteryBox5 = new MysteryBox<>();
        //mysteryBox5.setValue("红");

    }
}
